package com.tree.validationdemo.validator;

import com.tree.validationdemo.constraint.Gender;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author zhong
 * @version 1
 * @date 2022/04/10
 * @contact 1478168700@qq.com
 **/
public class GenderValidator implements ConstraintValidator<Gender, String> {


    /**
     * 初始化校验值
     */
    @Override
    public void initialize(Gender constraintAnnotation) {

    }

    /**
     * 校验规则
     */
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {

        return "男".equals(value) || "女".equals(value);
    }
}
